package com.xc.controller.backend;

import com.xc.common.ServerResponse;
import com.xc.pojo.SiteBanner;
import com.xc.service.ISiteBannerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 *  banner 为 mvc 关键字
 * @author mipha
 * @version 1.0
 * @date 2019/3/17 11:26 AM
 */
@Controller
@RequestMapping("/admin/banners/")
@Slf4j
public class AdminSiteBannerController {

    @Autowired
    ISiteBannerService iSiteBannerService;

    /**
     *  添加
     * @param siteBanner
     * @return
     */
    @RequestMapping("add.do")
    @ResponseBody
    public ServerResponse add(SiteBanner siteBanner){
        return iSiteBannerService.add(siteBanner);
    }


    /**
     *  修改banner
     * @param siteBanner
     * @return
     */
    @RequestMapping("update.do")
    @ResponseBody
    public ServerResponse update(SiteBanner siteBanner){
        return iSiteBannerService.update(siteBanner);
    }


    /**
     *  删除banner
     * @param id
     * @return
     */
    @RequestMapping("delete.do")
    @ResponseBody
    public ServerResponse delete(Integer id){
        return iSiteBannerService.delete(id);
    }


    /**
     *  列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse list(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iSiteBannerService.listByAdmin(pageNum,pageSize);
    }




}
